home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / NOWAIT.INC < prev    next >
Text File  |  1990-11-29  |  4KB  |  91 lines

  1. ;============================================================================
  2. ; A selection of Video macros
  3. ;Updated 9/26/90
  4. ;============================================================================
  5.  
  6. Wait_CGA_Retrace    Macro
  7.     Local   WAITV, WAITH, FINIS
  8. ;;------------------------------------------------------------------
  9. ;;Description: Snow prevention on a CGA, about 25% faster
  10. ;;than approach that merely uses horizontal retrace.
  11. ;;This macro waits for the first of the following to occur:
  12. ;; a vertical retrace (max memory move on a PC w/ CGA is 400 words;
  13. ;; however this routine is not used that way).
  14. ;; a horizontal retrace (max memory move on a CGA is 1 word)
  15. ;; Input:
  16. ;;  Call with CLI.  Assumes:  03DAh in DX, (CGA status register)
  17. ;; Modifies:
  18. ;;  DX and AL
  19. ;; Logic:
  20. ;;  if in the middle of vertical retrace, then end
  21. ;;    (and assume routine can move at least one word)
  22. ;;  if in the middle of horizontal retrace, wait until a
  23. ;;     new horizontal retrace starts, then end
  24. ;;    (and assume routine can move at least one word)
  25. ;; After write one word, turn on interrupts again STI !!!
  26. ;; Faster than just relying on horizontal retrace, because some CGA's
  27. ;; appear to turn off horizontal retrace when vertical retrace is on
  28. ;;------------------------------------------------------------------
  29. WAITV:
  30.     In    AL,DX    ;;Read CRT status register
  31.     Test    AL,8    ;;Check if vertical retrace
  32.     Jnz    FINIS    ;;if yes, assume that can write at least 1 word
  33.     Rcr    AL,1    ;;see if bit 1, Horizontal retrace set
  34.     Jc      WAITV   ;;if it is set start loop again
  35. WAITH:
  36.     In    AL,DX    ;;Read CRT status again
  37.     Rcr    AL,1    ;;Wait for horizontal retrace so we can start
  38.     Jnc     WAITH   ;;not yet, keep trying
  39. FINIS:            ;;rest of routine can now write at least one word
  40.     endm
  41.  
  42.  
  43.  
  44. comment         |*
  45. Set_DI_Offset     macro
  46.      ;; standard routine for 80 x 25 display
  47.      ;; Input  : COLL in DL, ROW in DH
  48.      ;; Returns: Offset within Video Segment in DI
  49.      ;; Uses & destroys DX,AX,CL
  50.      ;; Macro is used because inline code speeds routine
  51.              ;8088 ;80286
  52.      Xor   AX,AX     ;3    ;2
  53.      Mov   AL,DH     ;2    ;2  ;;put the current ROW number into AL
  54.      Mov   CL,160    ;4    ;2  ;;multiply by 160 to get start address of ROW
  55.      Mul   CL        ;77   ;13 ;;do the multiplication, answer ends up in AX
  56.      Xor   DH,DH     ;3    ;3  ;;clear DH for the Add below, we only want DL
  57.      Add   AX,DX     ;3    ;2  ;;add the column once for the character byte
  58.      Add   AX,DX     ;3    ;2  ;;and once more for the attribute byte
  59.      Mov   DI,AX     ;2    ;2  ;;now DI holds starting address on the screen
  60.      endm            ;-------
  61.              ;97   ;28  clocks
  62.     *|
  63.  
  64. Set_DI_Offset     macro
  65.     ;;This is slightly faster in the abstract
  66.     ;;sense on a 80286, though wont see it.
  67.     ;;Cannot observe the difference on a 8088 with a CGA,
  68.     ;;because of delay waiting for retrace
  69.     ;;
  70.     ;; Setup for 80 column display because that is all QBASIC supports
  71.     ;;
  72.     ;; Input:     DH = Row :  DL = Column
  73.     ;; Output:    DI = Memory Offset
  74.     ;; Destroys:  CX
  75.     ;; Macro is used because inline code speeds routine
  76.     ;;              ;8086  ;80286
  77.     Xor     CL, CL     ;3   ;2   ;; Clear CL
  78.     Mov     CH, DH     ;2   ;2   ;; CX = Row * 256
  79.     Shr     CX, 1      ;2   ;2   ;; CX = Row * 128
  80.     Mov     DI, CX     ;2   ;2   ;; Store in DI
  81.     Shr     DI, 1      ;2   ;2   ;; DI = Row * 64
  82.     Shr     DI, 1      ;2   ;2   ;; DI = Row * 32
  83.     Add     DI, CX     ;3   ;2   ;; DI = (Row * 128)+(Row * 32)={Row*160}
  84.     Xor     CH, CH     ;3   ;2   ;; Clear CH register
  85.     Mov     CL, DL     ;2   ;2   ;; CX = Columns
  86.     Shl     CX, 1      ;2   ;2   ;; Account for attribute
  87.     Add     DI, CX     ;3   ;2   ;; DI = (Row * 160) + (Col * 2)
  88.               ;--------
  89.       endm                ;26   ;22  ;; clocks
  90.  
  91.